package com.vic.designpattern.patterns.c_behavioral.state.demo3;

/**
 * 不及格状态
 * 分数小于60分为不及格
 * @author victor
 */
public class LowState extends AbstractState {

    public LowState() {

    }

    public LowState(ScoreContext context) {
        hj = context;
        stateName = "不及格";
        score = 0;
    }

    // 将上一次状态传递过来
    public LowState(AbstractState state) {
        // 实例化环境类
        hj = state.hj;
        stateName = "不及格";
        score = state.score;
    }

    // 调整 hj 中的 state
    @Override
    public void adjustState() {
        // 只需要调整为其它state
        if(score >= 90) {
            hj.setState(new HighState(this));
        } else if(score >= 60 && score < 90) {
            hj.setState(new MiddleState(this));
        }
    }
}
